﻿using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace BruteForce.Animation {
    public class ExplosionTransition : MapDrawableTransition {
        public double TextureSwitchDuration;
        public static List<Texture2D> Textures;
        public Vector2 Position;

        public ExplosionTransition(double duration, List<Texture2D> frames, double frameDuration, Vector2 position)
            : base(duration) {
            TextureSwitchDuration = frameDuration;
            Position = position;
            }

        public override Texture2D Texture
        {
            get {
                var cframe = (int)(Value / TextureSwitchDuration);
                return Textures[cframe % Textures.Count];
            }
        }

        public override Vector2 WorldLocation
        {
            get { return new Vector2(Position.X - (Textures[0].Width * TextureScale /2), Position.Y - (Textures[0].Height * TextureScale /2)); }
        }

        public override float TextureScale
        {
            get { return 1f; }
        }

        public override float Rotation
        {
            get { return 0; }
        }

        public override void Interpolate(GameTime time) {
            double t = Time / Duration;
            Value = t;
        }
    }
}